<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8"/>
		<title>事件绑定错误</title>
	</head>
	<body>
		<ul>
			<li>i为0</li>
			<li>i为1</li>
			<li>i为2</li>
			<li>i为3</li>
		</ul>
		<script type="text/javascript">
			var lists = document.getElementsByTagName('li');

			for(var i = 0, len = lists.length; i < len; i++) {
				(function (i) {
					lists[i].onclick = function() {
						alert('i=' + i);
					};
				})(i)
				
			}
                        alert('执行完毕，全局作用域中的i=' + i);
		</script>
	</body>
</html>